package main

import (
	"fmt"
	"gitee.com/stevenchin/gostudy/11network/socket1"
	"net"
)

/*
自定义协议解决TCP粘包之客户端
*/
func main() {

	conn, err := net.Dial("tcp", "127.0.0.1:30000")
	if err != nil {
		fmt.Println("dial failed, err", err)
		return
	}
	defer conn.Close()
	for i := 0; i < 20; i++ {
		msg := `Hello, Hello. How are you?`
		data, err := socket1.Encode(msg)
		if err != nil {
			fmt.Println("encode msg failed, err:", err)
			return
		}
		_, _ = conn.Write(data)
	}
}
